﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="membership_register_dialog.aspx.cs" Inherits="membership_register_dialog" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="ctl00_Head1">
    <title>曼福旅游保险</title> 
    <script src="_common/scripts/jquery/jquery-1.4.2.min.js" type="text/javascript"></script>
    <script type="text/javascript" src="_common/scripts/jquery_regform_validator.js"></script> 
    <script src="_common/scripts/util.js" type="text/javascript"></script> 
    <!-- ANALYTICS END -->
       <script type="text/javascript">
           $(document).ready(function () {  
               validator.setup("#form2");

               $("#txtUsername").blur(function () {
                   this.className = 'colorblur';
                   ValidateObjExisted("Username", "username");
               });
               $("#txtPassword").blur(function () {
                   this.className = 'colorblur';
                   ValidateObjExisted("Email", "email");
               });
           })

           function ValidateObjExisted(tagObjId, _otype) {
               bl = true;
               if ($("#txt" + tagObjId).val() != "") {
                   $.ajax({
                       type: "POST",
                       url: "register.aspx",
                       data: { _value: $("#txt" + tagObjId).val(), otype: _otype },
                       async: false,
                       success: function (data, textStatus) {
                           if (data == "existed") {
                               $("#span" + tagObjId).html(_otype.replace("username", "用户名已存在。").replace("email", "Email已存在。"));
                               $("#span" + tagObjId).fadeIn("slow");
                               bl = true;
                           } else {
                               $("#span" + tagObjId).html("");
                               $("#span" + tagObjId).fadeOut("slow");
                               bl = false;
                           }
                       }
                   });
               }
               return bl;
           }

           function ValidateSubmit() {
               var bl = validator.validatorAll();
               var bl1 = ValidateObjExisted("Username", "username");
               var bl2 = ValidateObjExisted("Email", "email");

               var bl3;
               if ($("#txtPasswordConfirm").val() == $("#txtPassword").val())
                   bl3 = true;
               else {
                   $("#spanPasswordConfirm").html("确认密码与密码输入不一致。");
                   $("#spanPasswordConfirm").fadeIn("slow");
                   bl3 = false;
               }

               if (!bl || !bl1 || !bl2 || !bl3) {
                   alert("验证失败！");
               }
               else {
                   $.ajax({
                       type: "POST",
                       url: prependOrgName("/membership_register_dialog.aspx"),
                       data: {
                           otype: "membership_register",
                           txtUsername: $("#txtUsername").val(),
                           txtPassword: $("#txtPassword").val(),
                           txtName: $("#txtName").val(),
                           txtEmail: $("#txtEmail").val()
                       },
                       async: false,
                       success: function (data, textStatus) {
                           if (data == "succeeded") {
                               alert("注册成功！");
                           }
                           else {
                               $("#divErrorMsg").css("display", "");
                               $("#ulMessageBody").html(data);
                           }
                       }
                   });
               }
           }
    </script>
</head>
<body>
    <form id="form2"> 
    <div class="clear">
    </div>
    <div id="borderedContainer" style="width: 520px;">
        <div class="leftCol" style="width: 500px;">
            <div class="form_width" style="width: 500px;">
                <!-- End of DoubleClick Floodlight Tag: Please do not remove -->
                <div class="fieldsetTop">
                </div>
                <div class="fieldsetMidd" style="width: 480px;">
                    <div class="form_content">
                        <div class="formcontent">
                            <p class="form_titles">
                                会员注册</p>
                            <div class="errorpaneltop" style="display: none;" id="divErrorMsg">
                                <div class="errorpanelbottom">
                                    <div class="errorcontent">
                                        <h3 class="error">
                                            错误提示</h3>
                                        <ul id="ulMessageBody"></ul>
                                    </div>
                                </div>
                            </div>
                            <div class="fieldsetBtm" style="width: 480px;">
                            </div>
                            <div>
                                <table border="0" class="quoteForm" style="padding-left: 5px;">
                                    <tbody>
                                        <tr>
                                            <td align="right" class="ControlTextLabels" style="height: 10px;">
                                                <span style="color: Red;">*</span>
                                                <label for="txtUsername">
                                                    用户名：</label>
                                            </td>
                                            <td>
                                                <input type="text" class="textbox" id="txtUsername" name="txtUsername" style="width: 150px;"
                                                    onfocus="this.className='colorfocus';" validatormsg="spanUsername" required="required"
                                                    controlname="用户名" isvalidator />
                                                <span class="alertPanel" id="spanUsername"></span>
                                            </td>
                                        </tr>
                                        <tr style="line-height: 8px;">
                                            <td>
                                                &nbsp;
                                            </td>
                                        </tr>
                                        <tr>
                                            <td align="right" class="ControlTextLabels" style="height: 10px;">
                                                <span style="color: Red;">*</span>
                                                <label for="txtPassword">
                                                    密码：</label>
                                            </td>
                                            <td>
                                                <input type="password" class="textbox" id="txtPassword" name="txtPassword" style="width: 150px;"
                                                    onblur="this.className='colorblur';" onfocus="this.className='colorfocus';" validatormsg="spanPassword"
                                                    required="required" controlname="密码" isvalidator />
                                                <span class="alertPanel" id="spanPassword"></span>
                                            </td>
                                        </tr> 
                                        <tr style="line-height: 8px;">
                                            <td>
                                                &nbsp;
                                            </td>
                                        </tr>
                                        <tr>
                                            <td align="right" class="ControlTextLabels" style="height: 10px;">
                                                <span style="color: Red;">*</span>
                                                <label for="txtPasswordConfirm">
                                                    确认密码：</label>
                                            </td>
                                            <td>
                                                <input type="password" class="textbox" id="txtPasswordConfirm" name="txtPasswordConfirm"
                                                    style="width: 150px;" onblur="this.className='colorblur';" onfocus="this.className='colorfocus';"
                                                    validatormsg="spanPasswordConfirm" required="required" controlname="确认密码" isvalidator />
                                                <span class="alertPanel" id="spanPasswordConfirm"></span>
                                            </td>
                                        </tr> 
                                        <tr style="line-height: 8px;">
                                            <td>
                                                &nbsp;
                                            </td>
                                        </tr>
                                        <tr>
                                            <td align="right" class="ControlTextLabels">
                                                <span style="color: Red;">*</span>
                                                <label for="txtName" >
                                                    姓名：</label>
                                            </td>
                                            <td>
                                                <input type="text" class="textbox" id="txtName" name="txtName" style="width: 150px;"
                                                    onfocus="this.className='colorfocus';" validatormsg="spanName" required="required"
                                                    controlname="姓名" isvalidator /> 
                                                <span class="alertPanel" id="spanName"></span>
                                            </td>
                                        </tr>  
                                        <tr style="line-height: 8px;">
                                            <td>
                                                &nbsp;
                                            </td>
                                        </tr>
                                        <tr>
                                            <td align="right" class="ControlTextLabels" style="height: 10px;">
                                                <span style="color: Red;">*</span>
                                                <label for="txtEmail">
                                                    E-Mail：</label>
                                            </td>
                                            <td>
                                                <input type="text" class="textbox" id="txtEmail" name="txtEmail" style="width: 200px;"
                                                    onfocus="this.className='colorfocus';" validatormsg="spanEmail" required="required"
                                                    controlname="E-Mail" isvalidator />
                                                <span class="alertPanel" id="spanEmail"></span> 
                                            </td>
                                        </tr>  
                                    </tbody>
                                </table>
                            </div>
                        </div>
                        <div class="fieldsetBtm" style="width: 480px;">
                        </div>
                        <input type="button" name="btnSubmit" id="btnSubmit" onclick="ValidateSubmit();" style="border-width: 0px; float: right;
                            margin-top: 10px; background: url('_imgs/login.gif') no-repeat; width: 195px; height: 41px; cursor: pointer;" />
                    </div>
                    <div class="clearBoth">
                    </div>
                </div>
            </div>
        </div>
        <div class="clearBoth">
        </div>
    </div>
    </form>
</body>
</html>
